<?php
include 'secure/core.php';
$SQL = "SELECT * FROM `settings`";
$res = $ado->exec($SQL);
$row	=	$ado->fetch($res);
?>
<?php
if(isset($_POST['submit']) && !empty($_POST['subject']) && isset($_POST['message'])){	 
	$sql ="select `email` from `users`";
	$email = $admin->getAdminEmail();	
	$res = $ado->exec($sql);
	if($ado->count($res) > 0){		
		while($ret = $ado->fetch($res)){
			$headers  = 'MIME-Version: 1.0' . "\r\n";
                        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";	
                        $headers .= "Reply-To: $to" . "\r\n";
                        $headers .= "From: ".$email . "\r\n";				
                        mail($ret['email'], $_POST['subject'], $_POST['message'], $headers);
		}
		header( 'Location: mass_email.php?msg=1' ) ;
	}
	else{
		header( 'Location: mass_email.php?msg=2' ) ;
	}
}
include 'header.php';
include 'left.php'; 
?>

		<div id="right">
		<div class="section">
		<?php if($_GET['msg'] == '1') { ?>
		<div class="message green"><span><b>Success</b>: Mass email has been sent.</span></div>
		<?php } ?>
		<?php if($_GET['msg'] == '2') { ?>
		<div class="message red"><span><b>Error</b>: Error sending email.</span></div>
		<?php } ?>
				<div class="box">
					<div class="title">
						Send Mass Email
						<span class="hide"></span>
					</div>
					<div class="content">
						<form action="mass_email.php" method="POST">
							<div class="row">
								<label>Send To</label>
								<div class="right">
                                                 <select class="ui-selectmenu ui-widget ui-state-default ui-selectmenu-dropdown ui-state-active ui-corner-top">
										<option value="">Select Option</option>
                                                                                <option value="1">All Members</option>
									</select>
								</div>
							</div>
							<div class="row">
								<label>Subject</label>
								<div class="right"><input type="text" name="subject" value=""></div>
							</div>
							<div class="row">
								<label>Message</label>
								<div class="right"><textarea name="message" id="message" rows="10" cols="80" class="required" title="Enter message to be sent."></textarea></div>
							</div>
							<div class="row">
								<div class="right">
								<button type="submit" class="green" name="submit"><span>Send</span></button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

<div id="footer">
			<div class="split">Copyright &#169; 2012 - <?php echo $file_path.$file_name; ?> <a href="index.html">Paid4Upload</a>.</div>
			<div class="split right"><a href="http://www.paid4upload.com/forums">Forums</a> | <a href="tos.php">Terms of Service</a> | <a href="dmca.php">DMCA</a></div>
		</div>
	</div>
</div>

</body>


</html> 